<?php

class SondageTable extends Doctrine_Table
{
	public function getSondage()
	{
		$q=Doctrine_Query::create()
		  -> select('s.id, s.proposition, g.titre ')
		  -> from('sondage AS s')
		  -> innerJoin('s.Groupesondage AS g')
		  -> where ('s.etat=?',1)
		  -> andWhere('g.etat=?',1)
		  -> orderBy('s.updated_at DESC');

		return $q->execute();
	}
	
	public function updateVote($valeur){
		$q = Doctrine_Query::create()
		  -> update('sondage')
		  -> set('vote','vote + 1')
		  -> where('id =?', $valeur);
		  
		return $q->execute();
	}
}